
import 'dart:convert';

import 'package:ysy_flutter_mvvm_yuanxuan/bean/login/LoginDataBean.dart';
import 'package:ysy_flutter_mvvm_yuanxuan/helper/Constant.dart';

import 'ConfigHelper.dart';
import 'SpHelper.dart';
import 'package:convert/convert.dart';
import 'package:crypto/crypto.dart';

//是否登录  true 登录  false 取消
bool isLogin(){
   var token = SPHelper.getToken();
   return token!=null && token.isNotEmpty;
}

LoginBean getLoginBean(){
   return SPHelper.getLoginInfo();
}

/// 获取发送验证码 必要的加密签名串
String getSendVerCodeSignature(Map<String, String> params) {
   String signatureStr = "";
   List<String> list=[];
   params.forEach((key, value) {
      list.add("$key=$value");
   });
   list.sort(); //升序
   list.forEach((element) {
      signatureStr+="${element}&";
   });
   //        val msg: String = signatureStr.substring(0, signatureStr.length - 1).toString() // 截取最后一个&
   signatureStr+="key=" +ConfigHelper.verificationCodeKey;
   var content = Utf8Encoder().convert(signatureStr);
   var digest = md5.convert(content);
   // 这里其实就是 digest.toString()
   return hex.encode(digest.bytes);
}